package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/29 11:46
 **/
public class Day44_5_Offer06_ReversePrint {
    class Solution {
        public int[] reversePrint(ListNode head) {
            int len = 0;
            ListNode cur = head;
            while(cur != null) {
                len++;
                cur = cur.next;
            }
            int[] ans = new int[len];
            while(head != null && --len >= 0){
                ans[len] = head.val;
                head = head.next;
            }
            return ans;
        }
    }
}